<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\datecontrol\DateControl;
use app\common\widgets\MyFileUpload;
use yii\bootstrap;

/* @var $this yii\web\View */
/* @var $model app\models\Msg */
/* @var $form yii\widgets\ActiveForm */
?>
<script type="text/javascript" src="js/qiniuupload/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/qiniuupload/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="js/qiniuupload/plupload/i18n/zh_CN.js"></script>
<script type="text/javascript" src="js/qiniuupload/ui.js"></script>
<script type="text/javascript" src="js/qiniuupload/qiniu.js"></script>
<script type="text/javascript" src="js/qiniuupload/highlight/highlight.js"></script>
<script type="text/javascript" src="js/qiniuupload/main.js"></script>

<div class="msg-form">

    <h4><?= Html::encode($model->isNewRecord ? '新建消息>>>' : '更新消息>>>') ?></h4>

    <div class="panel panel-default">
        <!--        <div class="panel-heading text-center" style="background: #003eff;color:white">msg</div>-->
        <div class="panel-body">
            <?php
            $form = ActiveForm::begin([
                        'options' => ['class' => 'form-horizontal form-group'],
                        'fieldConfig' => [
                            'template' => "{label}<div class=\"col-lg-8\">{input}</div>",
                            'labelOptions' => ['class' => 'col-lg-4 control-label'],
                        ]
            ]);
            ?>
            <div class="row">
                <div class="col-lg-12 col-xs-12 col-md-12 col-sm-12" onclick="change(this)">
                    <?= $form->field($model, 'msgtype')->radioList(['会议消息' => '会议消息', 'OA办文' => 'OA办文']) ?>
                </div>
            </div>

            <div class="row">
                <!--去掉是否转发和转发编号-->
                <!--                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                <?= $form->field($model, 'isforward')->dropDownList(['1' => '是', '0' => '否'], ['prompt' => '请选择']) ?>
                                </div>
                                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                <?= $form->field($model, 'forwardid')->textInput(['maxlength' => true]) ?>
                                </div>-->
                <div class="col-lg-12 col-xs-12 col-md-12 col-sm-12">
                    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
                </div>
                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <?= $form->field($model, 'content')->textarea(['rows' => 5]) ?>
                </div>

            </div>
            <div class="row" id="meeting">
                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <?=
                    $form->field($model, 'meetingtime_start')->widget(DateControl::className(), [
                        //日期组件的类型，是time 还是 date 或者 datetime(前提是要下载好相应的组件)
                        'type' => DateControl::FORMAT_DATETIME,
                        'ajaxConversion' => false,
                        'options' => [
                            'pluginOptions' => [
                                'autoclose' => true,
                                //设置开始日期
                                //'startDate' => date(date('Y-m-d')),
                                //设置结束日期
                                // 'endDate' => '2025-09-29',
                                //当前日期高亮显示
                                'todayHighlight' => true
                            ],
                            'options' => ['placeholder' => isset($model->meetingtime_start) ? $model->meetingtime_start : '请选择时间'],
                        ]
                            ]
                    )
                    ?>
                </div>
                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <?=
                    $form->field($model, 'meetingtime_end')->widget(DateControl::className(), [
                        //日期组件的类型，是time 还是 date 或者 datetime(前提是要下载好相应的组件)
                        'type' => DateControl::FORMAT_DATETIME,
                        'ajaxConversion' => false,
                        'options' => [
                            'pluginOptions' => [
                                'autoclose' => true,
                                //设置开始日期
                                //'startDate' => date(date('Y-m-d')),
                                //设置结束日期
                                // 'endDate' => '2025-09-29',
                                //当前日期高亮显示
                                'todayHighlight' => true
                            ],
                            'options' => ['placeholder' => isset($model->meetingtime_end) ? $model->meetingtime_end : '请选择时间'],
                        ]
                            ]
                    )
                    ?>
                </div>

                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <?php // echo $form->field($model, 'sendtime')->textInput(['maxlength' => true]) ?>

                    <?php
//                    echo $form->field($model, 'sendtime')->widget(DateControl::className(), [
//                        //日期组件的类型，是time 还是 date 或者 datetime(前提是要下载好相应的组件)
//                        'type' => DateControl::FORMAT_DATETIME,
//                        'ajaxConversion' => false,
//                        'options' => [
//                            'pluginOptions' => [
//                                'autoclose' => true,
//                                //设置开始日期
//                                //'startDate' => date(date('Y-m-d')),
//                                //设置结束日期
//                                // 'endDate' => '2025-09-29',
//                                //当前日期高亮显示
//                                'todayHighlight' => true
//                            ],
//                            'options' => ['placeholder' => isset($model->meetingtime_end) ? $model->meetingtime_end : '请选择时间'],
//                        ]
//                            ]
//                    )
                    ?>


                </div>



            </div>
            <div class="row">
                <!--                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                <?php // echo $form->field($model, 'isfinish')->dropDownList(['1' => '是', '0' => '否'], ['prompt' => '请选择']) ?>
                                </div>-->

                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <?= $form->field($model, 'meetingplace')->textInput(['maxlength' => true]) ?>
                </div>



            </div>
            <div class="row">

                <div class="col-lg-6 col-xs-12 col-md-6 col-sm-6">
                    <div class="form-group field-msg-meetingplace">
                        <label class="col-lg-4 control-label">接收对象</label>
                        <div class="col-lg-8">
                            <?= Html::Button('选择接收对象', ['class' => 'col-lg-12 col-md-12 btn btn-default', 'title' => '选择发送对象', 'id' => 'modalButton', 'data-toggle' => 'modal', 'data-target' => '#modal']); ?>
                        </div>
                    </div>              
                </div>

            </div>

            <div class="row">
                <div class="col-lg-12 col-xs-12 col-md-12 col-sm-12">
                    <label type="" id="selects" name="selects" value=""></label>
                </div>

                <input type="hidden" id="selects2" name="selects2" value="">

            </div>

            <?php if (!$model->isNewRecord) {
                ?>
                <div class="form-group">
                    <label class="col-lg-2 control-label"><h4>发送文件</h4></label>
                    <ul class="list-unstyled project-files col-lg-12">
                        <?php
                        foreach ($model->upfiles as $document) {
                            ?>
                            <li class="col-lg-2"  style="float:left">
                                <div class="media">
                                    <div class="media-left">
                                        <a href="<?= $document->path ?>">
                                            <?php
                                            $path = $document->path;
                                            $filetyep = strtolower(substr($path, strrpos($path, '.') + 1));

                                            if ($filetyep == "xls" || $filetyep == "xlsx") {
                                                ?>
                                                <img class="media-object" src="img/excel.png" alt="..." style="width:50px;height:50px;">
                                                <?php
                                            } else if ($filetyep == "doc" || $filetyep == "docx") {
                                                ?>
                                                <img class="media-object" src="img/word.jpg" alt="..." style="width:50px;height:50px;">
                                                <?php
                                            } else if ($filetyep == "ppt" || $filetyep == "pptx") {
                                                ?>
                                                <img class="media-object" src="img/ppt.png" alt="..." style="width:50px;height:50px;">
                                                <?php
                                            } else if ($filetyep == "txt") {
                                                ?>
                                                <img class="media-object" src="img/text.png" alt="..." style="width:50px;height:50px;">
                                                <?php
                                            } else if ($filetyep == "png" || $filetyep == "jpg" || $filetyep == "jpeg" || $filetyep == "bmp" || $filetyep == "gif") {
                                                ?>
                                                <!--<img class="media-object" src="img/zhaopian.png" alt="..." style="width:50px;height:50px;">-->
                                                <img class="media-object" src="<?= $path ?>" alt="..." style="width:50px;height:50px;">
                                                <?php
                                            } else {
                                                ?>
                                                <img class="media-object" src="img/file.png" alt="..." style="width:50px;height:50px;">
                                                <?php
                                            }
                                            ?>

                                        </a>
                                    </div>
                                </div>
                                <a href="<?= $path ?>"><?= $document->filename ?></a>
                            </li>

                            <?php
                        }
                        ?>
                    </ul>

                </div>

            <?php }
            ?>



            <div class="col-lg-12">
                <?= MyFileUpload::widget() ?>
            </div>

            <div class="form-group">
                <?= Html::submitButton('发送', ['class' => 'btn btn-success col-lg-offset-5 col-md-offset-5']) ?>
                <?= Html::a('返回', ['index'], ['class' => 'btn btn-primary']) ?>
            </div>

            <?php ActiveForm::end(); ?>
        </div>
    </div>

</div>


<?php
yii\bootstrap\Modal::begin([
    'header' => '添加发送对象',
    'id' => 'modal',
    'size' => 'modal-lg',
]);
?>   
<?php
echo $this->render('select_user');
?>
<?php yii\bootstrap\Modal::end() ?>



<script type="text/javascript">
    function change(obj) {
        var val = $('input:radio[name="Msg[msgtype]"]:checked').val();
        if (val == "会议消息") {
            $("#meeting").show();
        } else {
            $("#meeting").hide();
        }
    }
</script>

